<?php 
	if ((!defined("ADMIN-AREA")) || (!in_array(SHOWVIEW,$_SESSION['access']))) {
		die("No data");
	} else {
		unset($_SESSION['access']);
	}
	
	$statTambah = true;
	include_once "modul/funct_stat.php";

	if (ACT=="edit") {
		$sql1 = "SELECT * FROM tbl_content WHERE idx='".$_GET['kode']."' AND tipe LIKE 'bukutamu%' LIMIT 1";
		$qry1 = mysql_query($sql1);
		while ($row1 = mysql_fetch_object($qry1)) {
			$judul = $row1->judul;
			$isi = $row1->isi;
			$dataexpl = explode('#',$row1->header_c);
			$header_c = $dataexpl[0];
			$email = $dataexpl[1];
			$sender = $dataexpl[2];
			$website = $dataexpl[3];
			if (($row1->status)==1) {
				$pubx = "checked";
			};
		};
		
		$form_stat = "Edit";
	} else {
		$form_stat = "Input";
	}
	
	if ((ACT=="tambah") || (ACT=="edit")) {
?>
<form name="form1" method="post" action="<?php echo $path; ?>ver_gbook.php?show=<?php echo SHOW; ?>&amp;showview=<?php echo SHOWVIEW; ?>" onsubmit="MM_validateForm('<?php echo $GBOOK_IPADDRESS; ?>','','R','<?php echo $GBOOK_COMMENT; ?>','','R');return document.MM_returnValue">
  <table width="75%" border="0" align="center" cellpadding="4" cellspacing="1" class="content-arial">
    <tr valign="top"> 
      <td width="21%" valign="middle" nowrap> <div align="right"><?php echo $GBOOK_IPADDRESS; ?></div></td>
      <td width="5%" valign="middle"> <div align="center">:</div></td>
      <td valign="middle"> <div align="left">
          <input name="ipaddress" type="text" id="<?php echo $GBOOK_IPADDRESS; ?>" value="<?php echo $header_c; ?>" size="25" maxlength="30" class="input-title" />
      </div></td>
    </tr>
    <tr valign="top">
      <td nowrap="nowrap"><div align="right"><?php echo $GBOOK_EMAIL; ?></div></td>
      <td><div align="center">:</div></td>
      <td><div align="left">
          <input name="email" type="text" id="<?php echo $GBOOK_EMAIL; ?>2" value="<?php echo $email; ?>" size="25" maxlength="50" />
      </div></td>
    </tr>
    <tr valign="top">
      <td nowrap="nowrap"><div align="right"><?php echo $GBOOK_SENDER; ?></div></td>
      <td><div align="center">:</div></td>
      <td><div align="left">
          <input name="<?php echo $GBOOK_SENDER; ?>" type="text" id="<?php echo $GBOOK_SENDER; ?>" value="<?php echo $sender; ?>" size="32" maxlength="50" />
      </div></td>
    </tr>
    <tr valign="top">
      <td nowrap="nowrap"><div align="right"><?php echo $GBOOK_WEBSITE; ?></div></td>
      <td><div align="center">:</div></td>
      <td><div align="left">
          <input name="<?php echo $GBOOK_WEBSITE; ?>" type="text" id="<?php echo $GBOOK_WEBSITE; ?>" value="<?php echo $website; ?>" size="30" maxlength="50" />
      </div></td>
    </tr>
    <tr valign="top">
      <td nowrap><div align="right"><?php echo $GBOOK_COMMENT; ?></div></td>
      <td width="5%"><div align="center">:</div></td>
      <td width="74%"><div align="left">
        <textarea name="isi" cols="65" id="<?php echo $GBOOK_COMMENT; ?>" rows="20"><?php echo $isi; ?></textarea>
      </div></td>
    </tr>
    <tr valign="top"> 
      <td> <div align="right"><?php echo $GBOOK_PUBLISH; ?></div></td>
      <td> <div align="center">:</div></td>
      <td> <div align="left"> 
          <input name="publish" type="checkbox" id="publish" value="ya" <?php echo $pubx; ?> />
        </div></td>
    </tr>
    <tr valign="top"> 
      <td> <div align="right"></div></td>
      <td> <div align="center"></div></td>
      <td> <div align="left">
        <input type="submit" name="submit" id="submit" value="<?php echo $DEV_CTRL_SUBMIT; ?>" />
          <input type="reset" name="Reset" value="<?php echo $DEV_CTRL_RESET; ?>" />
<input name="act_ver" type="hidden" id="act_ver" value="<?php echo strtolower($form_stat); ?>">
          <input name="kode" type="hidden" id="kode" value="<?php echo (int) $_GET['kode']; ?>">
      </div></td>
    </tr>
  </table>
</form>
<?php
	} else {
		if (ACT<>"") {
			$act = ACT;
		} else {
			$act = "lihat";
		}
		echo $queryData->cari_form($GBOOK_SEARCH);
		$caridata = $queryData->cari_padaku("judul","isi");
?>
<table align="center" cellpadding="4" cellspacing="2" class="imagesSUB">
  <tr> 
    <th width="250" height="30" class="imagesSUB"><div align="center"><?php echo $GBOOK_COMMENT; ?></div></th>
    <th width="50" class="imagesSUB"><div align="center"><?php echo $GBOOK_PUBLISH; ?></div></th>
    <th width="75" class="imagesSUB"><div align="center"><?php echo $GBOOK_AUTHOR; ?></div></th>
    <th width="100" class="imagesSUB"> <div align="center"><?php echo $GBOOK_DATE; ?></div></th>
    <th width="50" class="imagesSUB"><div align="center"><?php echo $DEV_ACTION; ?></div></th>
  </tr>
<?php
		if (isset($_SESSION['isroot'])) {
			$sql1 = "SELECT * FROM tbl_content WHERE tipe LIKE 'bukutamu%' ".$caridata." ORDER BY tanggal DESC LIMIT ".$limitdown.",10";	
		} else {
			$sql1 = "SELECT * FROM tbl_content WHERE tipe LIKE 'bukutamu%' ".$caridata." ORDER BY tanggal DESC LIMIT ".$limitdown.",10";	
		}
		
		$qry1 = mysql_query($sql1);
		$numrow = mysql_num_rows($qry1);
		$num = 1;
		$x = 1;
		if ($numrow==0) {
			echo '<tr><th colspan="7">'.$DEV_NO_DATA.'</th></tr>';
		} else {
			while ($row1 = mysql_fetch_object($qry1)) {
				$data = $x % 2;
				if ($data==0) {
					$dataX = "ganjil";
				} else {
					$dataX = "genap";
				} 
?>
  <tr valign="top" class="<?php echo $dataX; ?>" onmouseover="setBG('bg<?php echo $x; ?>','#FFFFDD')" onmouseout="setBG('bg<?php echo $x; ?>','')" id="bg<?php echo $x; ?>"> 
    <td><div align="left"><?php echo substr(strip_tags($row1->isi),0,50); ?></div></td>
    <td><div align="center"><?php (($row1->status)==1) ? print "<img src=\"images/ico_check.gif\" width=\"16\" height=\"16\"></div></td>" : print "<img src=\"images/ico_delete.gif\" width=\"16\" height=\"16\"></div></td>";
?></div></td><td nowrap="nowrap"><div align="left"><?php echo $row1->author; ?></div></td>
    <td><div align="left"><?php echo $queryData->tanggalan($row1->tanggal,true);?></div></td>
<?php 
		echo $queryData->ctrl_data('','index.php?show='.SHOW.'&showview='.SHOWVIEW.'&act=edit&kode='.$row1->idx,$path.'ver_gbook.php?show='.SHOW.'&amp;showview='.SHOWVIEW.'&amp;kode='.$row1->idx.'&amp;act_ver=Hapus'); ?>
</tr>
<?php 
				$num++;
				$x++;
			}
		}
?>
</table>
<div align="center"><?php echo $queryData->next_prev($num,$pages_syarat,$limitdown); ?></div>
<?php
	}
?>